<script setup lang="ts">
  import { computed, ref } from 'vue'
  import { useUserStore } from '@/store/modules/user'
  import SvgIcon from '@/components/SvgIcon/index.vue'

  import HeaderAvatar from '@/views/userCenter/HeaderAvatar.vue'
  import FixUserInfo from '@/views/userCenter/fixUserInfo.vue'
  import ResetPwd from "./resetPwd.vue";


  const UserStore = useUserStore()

  //获取登录用户信息
  const userInfo = computed(() => UserStore.userInfo)
  // 默认打开标签
  const activeTab = ref('userinfo')
</script>

<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="7">
        <el-card class="box-card">
          <template v-slot:header>
            <div class="clearfix">
              <span class="text-bold">个人信息</span>
            </div>
          </template>

          <div>
            <div class="text-center" style="margin-left: calc(50% - 80px);">
              <!--修改头像-->
              <HeaderAvatar :userInfo="userInfo"></HeaderAvatar>
            </div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                <SvgIcon icon-class="user" />
                &nbsp;&nbsp;用户名称
                <div class="pull-right">{{ userInfo.username }}</div>
              </li>

              <li class="list-group-item">
                <SvgIcon icon-class="phone" />
                &nbsp;&nbsp;手机号码
                <div class="pull-right">{{ userInfo.phonenumber }}</div>
              </li>

              <li class="list-group-item">
                <SvgIcon icon-class="email" />
                &nbsp;&nbsp;用户邮箱
                <div class="pull-right">{{ userInfo.email }}</div>
              </li>
              <li class="list-group-item">
                <SvgIcon icon-class="email" />
                &nbsp;&nbsp;所属部门
                <div class="pull-right">
                  {{ userInfo.dept != null ? userInfo.dept.deptName : '无' }}
                </div>
              </li>
              <li class="list-group-item">
                <SvgIcon icon-class="peoples" />
                &nbsp;&nbsp;所属角色
                <div class="pull-right">{{ userInfo.roles }}</div>
              </li>
              <li class="list-group-item">
                <SvgIcon icon-class="date" />
                &nbsp;&nbsp;创建日期
                <div class="pull-right">{{ userInfo.createTime }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>

      <el-col :span="17">
        <el-card class="box-card">
          <template v-slot:header>
            <div class="clearfix">
              <span class="text-bold">基本资料</span>
            </div>
          </template>
          <el-tabs v-model="activeTab">
            <el-tab-pane label="基本资料" name="userinfo">
              <FixUserInfo :user-info="userInfo" />
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="resetPwd">
              <ResetPwd :user-info="userInfo" />
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
  @import './index';

  .list-group-striped > .list-group-item {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .list-group-item {
    border-bottom: 1px solid #e7eaec;
    border-top: 1px solid #e7eaec;
    margin-bottom: -1px;
    padding: 11px 0;
    font-size: 13px;
  }

  .pull-right {
    float: right !important;
  }

  ::v-deep .el-card__body {
    height: calc(100vh - 500px);
  }

  ::v-deep .box-card {
    //height: 450px;
    height: calc(100vh - 115px);
  }
</style>
